feat: implement build_priority for core components #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
In the CHP addon code we have to check, whether the linked component and the corresponding model variables are already initialized before we can add new constraints refering to both heatz and power component variables.
While this is fine in this specific case, it might become cumbersome for addons that link more than two components.
So it might be useful to have some way of specifying the build order of components in the config.
Changes
This adds the (optional) field
build_priority
to all core components. Before building the optimization models, all model components are sorted according to their build priority, and components with higher priority are initialized before components with lower priority.The default priority was set to 0 for all components and 1000 for Decisions.
I will also provide a PR to IESoptLib with changes to the CHP addon using this build priority.
I tested this locally, but ran into #12.
To have this tested properly, I would suggest first having the IESoptLib PR merged and afterwards re-running CI in this PR, but I am open to other suggestions.